<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="../style/ucs.css">
    <link rel="stylesheet" href="../content/font/iconfont.css">
    <link rel="stylesheet" href="../style/theme.css">
</head>
<body>
    <div id="giraffe"></div>
    <script type="text/javascript" src="../../dist/libs/u-eventhub.js"></script>
    <script type="text/javascript" src="../../dist/libs/engine.js"></script>
    <script type="text/javascript" src="../../dist/ucsmy-ui.js"></script>
    <script type="text/javascript">
        /*项目详情信息*/
        var ProDetailDM = new UDM({
            value: {
                "FinanceDetail": {
                    "login":true,
                    "loginUrl": "",
                    "confirmUrl": "",
                    "FinancingId":"",
                    "ProjectName":"",
                    "ProjectType":0,
                    "Duration":0,
                    "Interest":0,
                    "Progress":"",
                    "RealProgress":"",
                    "TotalAmount":"",
                    "ProjectBeginTime":"",
                    "JMBeginTime":"",
                    "ValueBegin":"",
                    "RepayBegin":"",
                    "MinAmount":"",
                    "GetMoneyChannel":1,
                    "RemainPartsCount":0,
                    "EachPartAmount":0,
                    "MinInvestPartsCount":1,
                    "AppendBuyAmount":0,
                    "ProjectStatus":0,
                    "IsExclusive":false,
                    "IsExclusivePublic":false,
                    "RepayType":0,
                    "ExclusiveCode":null,
                    "MaxLimitCount":0,
                    "TotalMaxLimitCount":0,
                    "ReFree":"",
                    "MaxInvestPartsCount":0,
                    "LoginFlag": 1,
//                    "InvestPromptText": "",
                    "BankName": "",
                    "PartsCount":0,
                    "FormatProjectBeginTime": "",
                    "FormatJMBeginTime": "",
                    "Aflag_Icon":""//活动标识
                },
                "GuaranteeList":[
                    {
                        "Title": "",
                        "Content": ""
                    },
                    {
                        "Title": "",
                        "Content": ""
                    }
                ],
                "ProjectContent": {
                    "Project_ContentId":"",
                    "FinancingId":"",
                    "Type":0,"Title":"",
                    "Content":""
                }
            },
            investClick: function(url){
                ajaxFnInvest(url);
            }
        });
        var InvestmentRecordDM = new UDM({
            value: ""
        });
        //分页条模型
        var paginationDM = new UDM({
            value: {	//默认值为0
                totalPage: 0,	//总页数
                pageSize: 1,	//每页显示条数
                curPage: 1	//当前页码
            },
            onClick:function(){
                ajaxFnPage();
            }
        });
        //收益计算公式 360天
        var daysDM = new UDM({
            value:360
        });

        //链接
        var URLDM = new UDM({
            home:"../Index/index.html",
            investList:"../InvestList/index.html"
        });

        /*ajax请求数据*/
        var ajaxFn = function(){
            var pageSize = paginationDM.getValue().pageSize;	//获取每页显示条数
            var curPage = paginationDM.getValue().curPage;		//获取当前选中页码

            var ProjectDetail = {
                "FinanceDetail": {
                    login:false,
                    loginUrl:"http://www.baidu.com",
                    confirmUrl:function(){
                        console.log(ProDetailDM.getValue().FinanceDetail.PartsCount)
                    },
                    "FinancingId":"00ccff26-9343-40ef-b3da-9bf92068349e",
                    "ProjectName":"乐盈【201608110020】",
                    "ProjectType":0,
                    "Duration":95,
                    "Interest":8.60,
                    "Progress":"60",
                    "RealProgress":"0",
                    "TotalAmount":"78000.00",
                    "ProjectBeginTime":"2017-08-11 17:18:26",
                    "JMBeginTime":new Date(new Date().getTime() + 10000),
                    "ValueBegin":"2016-08-27",
                    "RepayBegin":"2016-11-30",
                    "MinAmount":"1000.00",
                    "GetMoneyChannel":1,
                    "RemainPartsCount":78000,
                    "EachPartAmount":1000.00,
                    "MinInvestPartsCount":2,
                    "AppendBuyAmount":1000.00,
                    "ProjectStatus":1,
                    "IsExclusive":true,
                    "IsExclusivePublic":false,
                    "RepayType":0,
                    "ExclusiveCode":null,
                    "MaxLimitCount":20000.00,
                    "TotalMaxLimitCount":500000.00,
                    "ReFree":"13608040001",
                    "MaxInvestPartsCount":10,
                    "LoginFlag": 1,
//                    "InvestPromptText": "您最多可以购买10000份",
                    "BankName": "新昌农村商业银行",
                    "PartsCount":1000,
                    "FormatProjectBeginTime": "2017-08-11",
                    "FormatJMBeginTime": "2017-08-25",
                    "Aflag_Icon":"icon_xs.png|只有新用户才能投标,icon_qt.png,icon_jj.png"//活动标识
                },
                "GuaranteeList":[
                    {
                        "Title": "融资方经营场所实地认证",
                        "Content": "4"
                    },
                    {
                        "Title": "融资方从业年限",
                        "Content": "4"
                    }
                ],
                "ProjectContent": {
                    "Project_ContentId":"9c575900-b56e-46fb-9985-c87010c936b7",
                    "FinancingId":"00ccff26-9343-40ef-b3da-9bf92068349e",
                    "Type":0,"Title":"融资用途",
                    "Content":"融资企业为_____企业，企业规模_____，行业类型为_____，经营范围是_____，融资款具体用途是_____。填写之后将会在前端显示；"
                }
            }
            ProDetailDM.setValue(ProjectDetail);
            var InvestmentRecord = {
                "PageIndex":1,
                "TotalCount":0,
                "InvestmentRecord":[

                ]
            }

            var paginationValue = {
                totalPage: Math.ceil(InvestmentRecord.InvestmentRecord.length/pageSize),	//总页数
                pageSize: pageSize,	//每页显示条数
                curPage: curPage	//当前页码
            }
            var curInvestmentRecord = [];
            if(InvestmentRecord.InvestmentRecord.length>0){
                for(var i = curPage*pageSize - pageSize ; i < curPage*pageSize ; i ++){
                    curInvestmentRecord.push(InvestmentRecord.InvestmentRecord[i]);
                }
            }
            paginationDM.setValue(paginationValue);
            InvestmentRecordDM.setValue(curInvestmentRecord);
        };

        var ajaxFnPage = function(){
            var pageSize = paginationDM.getValue().pageSize;	//获取每页显示条数
            var curPage = paginationDM.getValue().curPage;		//获取当前选中页码

            var InvestmentRecord = {
                "PageIndex":1,
                "TotalCount":2,
                "InvestmentRecord":[
                    {
                        "PayUserName":"彭**",
                        "PayAmount":"1,000.00",
                        "PayTime":"2016-08-09 10:05:38"
                    },
                    {
                        "PayUserName":"麦**",
                        "PayAmount":"600.00",
                        "PayTime":"2016-08-09 10:05:31"
                    }
                ]
            }

            var paginationValue = {
                totalPage: Math.ceil(InvestmentRecord.InvestmentRecord.length/pageSize),	//总页数
                pageSize: pageSize,	//每页显示条数
                curPage: curPage	//当前页码
            }
            var curInvestmentRecord = [];
            if(InvestmentRecord.InvestmentRecord.length>0){
                for(var i = curPage*pageSize - pageSize ; i < curPage*pageSize ; i ++){
                    curInvestmentRecord.push(InvestmentRecord.InvestmentRecord[i]);
                }
            }
            paginationDM.setValue(paginationValue);
            InvestmentRecordDM.setValue(curInvestmentRecord);
        };

        var ajaxFnInvest = function(url){
            console.log(url);
        }

        var PageDM = {
            ProDetail: ProDetailDM,
            InvestmentRecord: InvestmentRecordDM,
            pagination: paginationDM,
            days:daysDM,
            URL:URLDM
        }
        UEventHub.on('pageLoad',function(){
            ajaxFn();
        });
    </script>
<script type="text/javascript" src="../ProDetail\index.js"></script></body>
</html>